﻿package config;

import java.io.FileWriter;
import java.io.IOException;

/* *
 *类名：AlipayConfig
 *功能：基础配置类
 *详细：设置帐户有关信息及返回路径
 *修改日期：2017-04-05
 *说明：
 *以下代码只是为了方便商户测试而提供的样例代码，商户可以根据自己网站的需要，按照技术文档编写,并非一定要使用该代码。
 *该代码仅供学习和研究支付宝接口使用，只是提供一个参考。
 */

public class AlipayConfig {
	
//↓↓↓↓↓↓↓↓↓↓请在这里配置您的基本信息↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

	// 应用ID,您的APPID，收款账号既是您的APPID对应支付宝账号
	public static String app_id = "2016101800714113";
	
	// 商户私钥，您的PKCS8格式RSA2私钥
    public static String merchant_private_key = "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQChTmipIS23Qbolw8G64Xp1kD0nZK61oyl1Pz5DG39MUW8r9fMWoBu4mciLlUL3NhdC/Fd+fKb+SZvOfvWZduabNuQPfYlrGj/LH3s6sbFnj0a4atEMwD2n6+ePvK88MA/7en5znkQfed3XyZbyyR8CRBEgtDvuHUP4dS3F9MUfYBfCJELK0UlEK8MDU7aM8pHwrVM1VBTv9RTkIJXjxEV7yfih/oBMcGGkY96djvvFlV6RnkCFfTjj2HzUmDSR5gAuGvFHIzZtmlX3KtVOEJqgUpXVYQcQZ/xpdD/kbHvsS0HPyWmsoDpauCEC5+3W8Tlx0RiRBONCrjn1kTeXt8aBAgMBAAECggEBAJNMjJpVZ+++n4O43QIQwMj2bEG62SeY1VTx6aNSSs6gVoqoT9FLZ8UM+WstZDdnN5q94A/rOHthMFxC53e6ch8u4teaZZBeKf8MwnT4qu3MkmH5eOjR6/uZmp1RShwGL7IPS8W8sqyjlodk2Ojf6+cfzRw2ObvZEaajKqdoO1HH8K9N8eeeQpoJOSQlNjxrcJB5juEGp+O1jIQK3trDm1zXcBK9rVhH6W0CuoMpbDYakn3uKb+YWjV/TltfSJdSprXrLxXJUhPn9Olpz9c3Kd6yGkNvWjNmZn/mup/KA4wWlgQX1/kUd2jq++uLBK3UtOkV4IvQw9Ek9GRl89vpNSECgYEA7Mc6IZLZf8DEW0pnIw/5h2VRIVt2CfQV0XJKB8Nz890je0Lov94w6+5hOkzU//WG264VxppNefFiSIb46kysMiGbWsIr5w62bCsoK9fDEe7Z36PJK4RWJRPLxbxYigzVCAzE7kl2rXayoOYdXFKIJQZkMpGXmZYIIoNW2SXOgGUCgYEArma1Y8fZoPogX8TFjcZaWnoRwgW3GGWikj2cVSQX3KZdIfuoC/uM3o1YqtfvQpe5rKmCISz57OXyiftHcc1ESPOjHSH89zYxTzssvXXCdFlwDLTxuVTRKd/wyvWFny+BKtsGNbnpPPYUfFiLxYnPvXbrmpe9XezYKu3rP5y+Ne0CgYBhIBwNV5KWX/lrxSpnbI8b5giQmVbjIFeu0aXiZ19yAh0i28Bjq/3/WYpSgt/AmvOVu2Q9UmBDjCuXup3yZj8gVT7HzOx7XEKiPlW9HkVrXsHKhgHoMuGvVd55nxfmkPr10V8aq9Hdt9nwPFSA4W3tWiDRyX0ZSDzQA3YlnueFLQKBgA9RPgUxfE/DKCzBH4jALxdbOUwNLHOcGZc2ihCARwg+JFfjvnKu+URirbLznDQBF3GuwZsgVCMWXyL3SuMX4DN4Eo9weMNNoy8OR3OscBO/9zNmgQSCCoze+ksZHU9J4NJewkDdvzp3cn0pWb1TyUcetrqxMRSaxLGgi9Tec2ZRAoGBALZzTHx7tlC2WYgaTk1mA4dFYQUpr6Vt8/ZHxQLZMe47ENWwoW1Hcz2O0aG7FDfDyI1aorPzwOh95lcbYrGEbcA9Tf0hdfv4k+upnlV4K1s1ZCORdgDHfweFhL5o/dNqLmZnSlpiW8EuuGCHUeDUmdowKYtoAGUZaT1aUn9eC+UJ";
	
	// 支付宝公钥,查看地址：https://openhome.alipay.com/platform/keyManage.htm 对应APPID下的支付宝公钥。
    public static String alipay_public_key = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqhsLk5/W/wJnO2bpOKVflY4v6z6o3Q/bhOT02SZ63w3JWkHvRVZXYS6MQ8gbqGdsZi7UuSIrJ+nSx7VTyEK7EIC/JleEuwHNGSyPgNzAl95f5yV2jVIcKRoguZmIAWRdZRy0zNiK0FmZnXY9H9HxE7o1aVdAbp6Vqtnme25wlCJa6ub6pk1cmDxkOhCHsUciUxmpdk1YjequUL/vPaUFrNR/tn9QEe4zPsjb/95CiNUUt6lOEJV+AyRF6CBAbextUrfrZlfkAdHL/3am6QT5ZIy57NdRrC2TdieJUjXhnGk5sXustWxscrIs3zFYKdGQmKsOHagzMjTw3rVp/Ea1gwIDAQAB";

	// 服务器异步通知页面路径  需http://格式的完整路径，不能加?id=123这类自定义参数，必须外网可以正常访问
	public static String notify_url = "http://cyw.mynatapp.cc/pay-demo/aliPayNotifyUrlServlet";

	// 页面跳转同步通知页面路径 需http://格式的完整路径，不能加?id=123这类自定义参数，必须外网可以正常访问
	public static String return_url = "http://cyw.mynatapp.cc/pay-demo/aliPayReturnUrlServlet";

	// 签名方式
	public static String sign_type = "RSA2";
	
	// 字符编码格式
	public static String charset = "utf-8";
	
	// 支付宝网关
	public static String gatewayUrl = "https://openapi.alipaydev.com/gateway.do";
	
	// 支付宝网关
	public static String log_path = "C:\\";


//↑↑↑↑↑↑↑↑↑↑请在这里配置您的基本信息↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑

    /** 
     * 写日志，方便测试（看网站需求，也可以改成把记录存入数据库）
     * @param sWord 要写入日志里的文本内容
     */
    public static void logResult(String sWord) {
        FileWriter writer = null;
        try {
            writer = new FileWriter(log_path + "alipay_log_" + System.currentTimeMillis()+".txt");
            writer.write(sWord);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (writer != null) {
                try {
                    writer.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}

